<?php
require_once  __DIR__ . '/includes/authenticate.php';
include_once './db_bb_connect.php';

?>
<h4> Add New Season</h4>

<h5>Available seasons:</h5>
<select class="form-control"  name="">
		<option selected="selected" disabled="disabled"> Show available seasons</option>

<?php

$sql = "SELECT season FROM seasons";

$result = $db->query ($sql);

while ($row = $result->fetch_assoc()) {
	$season = $row['season'];

	echo "<option value=\"\"> $season </option>";
}
?>
</select>

<br>


<h5>Add season:</h5>

<form>
	<input class="form-control" type="text" name="season" placeholder="type the season name" />
<br>
	<button class="btn btn-success" id="addnewseasonsubmit" type="submit" name="submit">Add Season </button>

</form>

<script type="text/javascript">

$("#addnewseasonsubmit").on("click", function(e) {
    postData = $(this.form).serialize();
    $.ajax({
        type: "POST",
        url: "./includes/handlers/admin_addnewseason_handler.php",
        data: postData,
        success: function(data) { 
            $("#admintoolscontent").html(data); 
        },
        error: function (xhr, status, error) {
        	$("#admintoolscontent").html(xhr.responseText); 
        }
      }); 
    e.preventDefault();
});  

</script>